using System;
using FytSoa.Common.Utils;
using System.ComponentModel.DataAnnotations;
using FytSoa.Application.Sys;
using FytSoa.Domain.Crm;
using SqlSugar;

namespace FytSoa.Application.Crm;

/// <summary>
/// 工单
/// </summary>
public class CrmWocOrderDto : AppEntity
{
    /// <summary>
    /// 客户编号
    /// </summary>
    [Required]
    public long CustomerId { get; set; }
    
    /// <summary>
    /// 客户信息
    /// </summary>
    public CrmCustomerDto CustomerObj { get; set; }

    /// <summary>
    /// 工单编号
    /// </summary>
    [Required]
    [StringLength(50)]
    public string Number { get; set; }

    /// <summary>
    /// 工单说明-标题
    /// </summary>
    [Required]
    [StringLength(500)]
    public string Title { get; set; }

    /// <summary>
    /// 状态（1=待接受2=处理中3=待审核4=已完成5=已关闭）
    /// </summary>
    [Required]
    public int Status { get; set; } = 1;

    /// <summary>
    /// 来源
    /// </summary>
    [Required]
    public long Source { get; set; }
    
    /// <summary>
    /// 来源
    /// </summary>
    public SysCodeDto SourceObj { get; set; }

    /// <summary>
    /// 工单类型
    /// </summary>
    [Required]
    public long Type { get; set; }
        
    /// <summary>
    /// 工单类型
    /// </summary>
    public SysCodeDto TypeObj { get; set; }

    /// <summary>
    /// 级别
    /// </summary>
    [Required]
    public long Level { get; set; }

    /// <summary>
    /// 级别
    /// </summary>
    public SysCodeDto LevelObj { get; set; }

    /// <summary>
    /// 标签
    /// </summary>
    public List<string> Tags { get; set; } = new();

    /// <summary>
    /// 处理限时
    /// </summary>
    public DateTime? TimeLimit { get; set; }

    /// <summary>
    /// 附件
    /// </summary>
    public string Files { get; set; }

    /// <summary>
    /// 派单人流程
    /// </summary>
    [Required]
    public List<CrmWocOrder.SendUserProgress> SendUser { get; set; } = new();
    
    /// <summary>
    /// 用户派单流转具体信息，提供详情查看使用，添加不需要
    /// </summary>
    public List<SendUserInfo> SendProgressUser { get; set; } = new();
    
    /// <summary>
    /// 最后执行人，添加不需要
    /// </summary>
    public SendUserInfo LastUser { get; set; } = new();

    /// <summary>
    /// 关联工单列表-数组
    /// </summary>
    public List<CrmWocOrder.RelevanceOrder> Relevance { get; set; } = new();

    /// <summary>
    /// 最后处理人
    /// </summary>
    public long LastProcessUserId { get; set; } = 0;

    /// <summary>
    /// 审核信息反馈
    /// </summary>
    public CrmWocOrder.AuditSuccess AuditSummary { get; set; } = new();
    
    /// <summary>
    /// 驳回
    /// </summary>
    public CrmWocOrder.RejectJson Reject { get; set; } = new ();
    
    /// <summary>
    /// 关闭原因
    /// </summary>
    public CrmWocOrder.CloseJson CloseRemark { get; set; } = new ();
    
    /// <summary>
    /// 创建时间
    /// </summary>
    [Required]
    public DateTime CreateTime { get; set; } = DateTime.Now;

    /// <summary>
    /// 创建人
    /// </summary>
    public string CreateUser { get; set; }

    /// <summary>
    /// 修改时间
    /// </summary>
    public DateTime? UpdateTime { get; set; }

    /// <summary>
    /// 修改人
    /// </summary>
    public string UpdateUser { get; set; }

    /// <summary>
    /// 用户信息，提供详情查看使用
    /// </summary>
    public class SendUserInfo:CrmWocOrder.SendUserProgress
    {
        /// <summary>
        /// 头像
        /// </summary>
        public string Avatar { get; set; }

        /// <summary>
        /// 姓名
        /// </summary>
        public string FullName { get; set; }
        
        /// <summary>
        /// 机构
        /// </summary>
        public string Organization { get; set; }
        
        /// <summary>
        /// 角色
        /// </summary>
        public string Role { get; set; }
    }
}